<%@ Page Language="C#" Theme="Defaultsys" AutoEventWireup="true" CodeFile="AssignedLetterList.aspx.cs"
    Inherits="AssignedLetterList" Title="Rapport Plan System - Assign letter list"
    MasterPageFile="~/MasterPage.master" %>

<%@ MasterType VirtualPath="~/MasterPage.master" %>
<asp:Content runat="server" ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1">

    <script type="text/javascript" language="javascript">
    var checkflag = "false";

    function CheckAll(id)
    {
	    if (checkflag == "false") 
	    {
		    var el = document.getElementById(id);
		    for (var i = 0; i < el.elements.length; i++) 
		    {
		      el.elements[i].checked = "true";
		    }
		    checkflag = "true";
		    return "Uncheck All"; 		
	    }
	    else
	    {
		    var el = document.getElementById(id);
		    for (var i = 0; i < el.elements.length; i++) 
		    {
		      el.elements[i].checked = false;
		    }
		    checkflag = "false";
		    return "Check All"; 				
	    }
	    
    }
    </script>

    <table border="0" width="100%" cellpadding="0" cellspacing="0">
        <tr>
            <td class="contTable">
                <div style="display: none; color: Red; font-size:smaller" id="lblQuestion" runat="server">
                    Check the letters printed correctly
                </div>
                <asp:GridView ID="grdLetters" SkinID="gvGrid" runat="server" AutoGenerateColumns="false"
                    Width="100%" DataKeyNames="LetterId" AllowPaging="true" OnPageIndexChanging="grdLetters_PageIndexChanging">
                    <Columns>
                        <asp:TemplateField HeaderText="ID" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"
                            HeaderStyle-Width="3%">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1 %>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Letter" HeaderStyle-Width="30%" 
                            HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left">
                            <ItemTemplate>
                                <asp:HyperLink ID="id" runat="server" NavigateUrl='<%# "Letter.aspx?id="+Global.EncryptString(Eval("LetterId").ToString())%>'
                                    Target="_blank"><%# Eval("LetterName")%></asp:HyperLink>
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:BoundField HeaderText="From" DataField="From" SortExpression="From" DataFormatString="{0:MM/dd/yyyy}"
                            HtmlEncode="false" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" />
                            
                        <asp:BoundField HeaderText="To" DataField="DaysTo" SortExpression="DaysTo" DataFormatString="{0:MM/dd/yyyy}"
                            HtmlEncode="false" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left"/>
                            
                        <asp:TemplateField HeaderText="Print" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:CheckBox ID="ckLetter" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        
                        <asp:TemplateField HeaderText="Id" Visible="false">
                            <ItemTemplate>
                                <asp:TextBox ID="idLetter" runat="server" Visible="false" Text='<%# Eval("LetterId") %>'></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <EmptyDataTemplate>
                        There are currently no letters.</EmptyDataTemplate>
                    <PagerStyle VerticalAlign="Middle" HorizontalAlign="Left" Wrap="False" CssClass="paging"
                        Font-Bold="True"></PagerStyle>
                    <PagerSettings Mode="NumericFirstLast" />
                </asp:GridView>
                <asp:Button ID="btnCheckAll" runat="server" Text="Check all" />
                <asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_Click" />
                <br />
                <div style="display: none; color: Red" id="lblWarning" runat="server">
                    No letter is selected.
                </div>
                <asp:HiddenField ID="txtHidden" runat="server" Value="Print" />
            </td>
        </tr>
    </table>
</asp:Content>
